﻿using System;
using System.Net;

namespace com.igetui.api.openservice
{
	// Token: 0x02000027 RID: 39
	internal class HttpProxy
	{
		// Token: 0x0600046C RID: 1132 RVA: 0x00009AE8 File Offset: 0x00007CE8
		public HttpProxy(IGtHttpProxy p)
		{
			if (!string.IsNullOrWhiteSpace(p.Host) && p.Host.Length > 0)
			{
				this.isProxy = true;
			}
			else
			{
				this.isProxy = false;
			}
			if (p.User == null)
			{
				p.User = "";
			}
			if (p.Password == null)
			{
				p.Password = "";
			}
			if (!string.IsNullOrWhiteSpace(p.User) || !string.IsNullOrWhiteSpace(p.Password))
			{
				this.isProxyAuth = true;
			}
			else
			{
				this.isProxyAuth = false;
			}
			this.proxy = p;
		}

		// Token: 0x0600046D RID: 1133 RVA: 0x00009B80 File Offset: 0x00007D80
		public WebProxy getWebProxy()
		{
			WebProxy webProxy = null;
			if (this.isProxy)
			{
				webProxy = new WebProxy();
				if (!this.proxy.Host.ToLower().StartsWith("http"))
				{
					this.proxy.Host = "http://" + this.proxy.Host;
				}
				webProxy.Address = new Uri(this.proxy.Host + ":" + this.proxy.Port);
				if (this.isProxyAuth)
				{
					webProxy.Credentials = new NetworkCredential(this.proxy.User, this.proxy.Password);
				}
			}
			return webProxy;
		}

		// Token: 0x040002B4 RID: 692
		private IGtHttpProxy proxy;

		// Token: 0x040002B5 RID: 693
		private bool isProxy;

		// Token: 0x040002B6 RID: 694
		private bool isProxyAuth;
	}
}
